import React, { PropTypes } from 'react'
import { Form,Input,Select, Button, Row, Col,Modal } from 'antd'
import SearchGroup from '../ui/search'

const Search = Input.Search;
const Option = Select.Option;

class ExGoodsSearch extends React.Component {
	 constructor (props) {
    	super(props);
    	this.state={
				keywords:''
			}
   }
	search(){	
			let keywords = document.getElementById('customer').value	
			if(keywords==''){
				const modal  = Modal.error({
				content:'订单检索不能为空'
			})
				setTimeout(()=>modal.destroy(),2000);
				return
			}
			this.props.onSearch({
				keywords: this.state.keywords
		})
	}
	inputChange(key,e){
		const { value } = e.target;
		this.state[key]=value.replace(/\s+/g,'')
	}
	reset(){
		document.getElementById("customer").value=""
		this.setState({
			"keywords":""
		})
		this.props.onClear()
	}

		render(){
			return (  	
		    <Row gutter={24}>
					<Row gutter={24}>
						<Col lg={6} md={6} sm={12} xs={24}>
							<span>订单检索：</span>
							<Input id="customer" placeholder="输入取件人名称或电话" onChange={(e)=>this.inputChange('keywords',e)}/>
						</Col>
						<Col lg={6} md={6} sm={12} xs={24}>
							<Button type="primary" style={{marginTop:18}} onClick={this.search.bind(this)}>搜索</Button>
						</Col>
						<Col lg={6} md={6} sm={12} xs={24}>
							<Button type="primary" style={{textAlign:'right',marginTop:18}} onClick={this.reset.bind(this)}>重置</Button>
						</Col>
					</Row>
		  </Row>
			
		  )
		}
}

ExGoodsSearch.propTypes = {
  form: PropTypes.object.isRequired,
  onSearch: PropTypes.func,
  onAdd: PropTypes.func,
  field: PropTypes.string,
  keyword: PropTypes.string
}

export default Form.create()(ExGoodsSearch)
